<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends AppController {
	public function __construct(){
		parent::__construct();
	}
	
	public function index(){
	}
	
	public function admin_index(){
		$static = $this->getEM()->getRepository('Entity\StUser');
		$this->data['statistic'] = array(
			'resource' => $static->resource(),
			'website' => $static->website()
		);
		
		$this->data['breadcrumb']['Bảng điều khiển'] = null;
		$this->render('page/admin_index');
	}
	
	public function admin_config(){
		$this->validation();
		if($this->input->post() && $this->form_validation->run('config')):
			if($this->page_model->update_config()):
				$this->session->set_flashdata('success','Sửa cấu hình thành công');
				redirect('/admin/page');
			else:
				$this->data['flash'] = array('error' => 'Lỗi sql, thử lại');
			endif;
		endif;

		$this->data['config'] = $this->getEM()->getRepository('Entity\StConfig')->basicConfig();
		$this->data['breadcrumb'] = array(
			'Bảng điều khiển' => site_url('/admin/page'),
			'Cấu hình chung' => null
		);
		$this->render('page/admin_config',
			array('jquery.sceditor.bbcode.min','language/vi','sceditor'),
			array('default.min','tabs')
		);
	}
}